package day07;


import java.util.Arrays;
import java.util.Scanner;

public class CalTotalAvg {
    public static void main(String[] args) {
        double[] arr=score();
        double sum=totalScore(arr);
        double avg=scoreAvg(arr);
        System.out.println("平均分为："+avg);
    }
    public static double[] score(){
        Scanner scan=new Scanner(System.in);
        double arr[]=new double[6];
        for(int i=0;i<arr.length;i++){
            System.out.println("请输入第"+(i+1)+"评委的分数：");
            arr[i]=scan.nextDouble();
        }
        return arr;
    }
    public static double totalScore(double[] arr){
        double max=arr[0];
        double min=arr[0];
        double sum=0;
        for(int i=0;i<arr.length;i++){
            if(arr[i]>max){
                max=arr[i];
            }
            if(arr[i]<min){
                min=arr[i];
            }
            sum+=arr[i];
        }
        return sum-max-min;

        /*
        Arrays.sort(arr);
        double []newArray=new double[4];
        System.arraycopy(arr,1,newArray,0,4);
        double sum=0;
        for(int i=0;i<newArray.length;i++){
            sum+=newArray[i];
        }
        return sum;

         */

    }
    public static double scoreAvg(double[]arr){
        double sum=totalScore(arr);
        double avg=sum/(arr.length-2);
        return avg;
    }
}
